/*qa82Pm79QnBpcraP5omSXLrYfsEcyDp+BoZhT2qxOjjvhyl83NPaFo273vGkCOZo*/
/**
 * 公共方法
 */
import { cardCache } from 'nc-lightapp-front';
import ampub from 'ampub';
import constants from '../../constants';
import { setBatchBtnsEnable } from './rowSelected';

const { utils: { msgUtils: { MsgConst, showMessage, showErrorMessageByRes }, listUtils: { setListValue } } } = ampub;
const { assetDataSource, AREA: { LIST: { GRID_AREA: tableId } } } = constants;

//列表态——列表查询回调处理
const listQueryBackHandler = {
	success: (props, res, scene) => {
		let { success, data } = res;
		if (success) {
			setListValue.call(this, props, res, tableId, scene);
			setBatchBtnsEnable.call(this, props, tableId);

			//取出 pk2ClientKeyMap 并存到缓存中
			if (data) {
				cardCache.setDefData(constants.pk2ClientKeyMap, assetDataSource, JSON.parse(data.userjson));
			}
		} else {
			props.table.setAllTableData(tableId, { rows: [] });
			/*国际化处理：未查询出符合条件的数据*/
			showMessage(props, { type: MsgConst.Type.QueryNoData });
		}
	},
	error: (props, res) => {
		showErrorMessageByRes(props, res);
	}
};

export { listQueryBackHandler };

/*qa82Pm79QnBpcraP5omSXLrYfsEcyDp+BoZhT2qxOjjvhyl83NPaFo273vGkCOZo*/